<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>阿呆社区</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrap-theme.min.css}">
    <link rel="shortcut icon" th:href="@{img/shotcut.png}">
    <script th:src="@{/js/jquery-3.4.1.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">阿呆社区</span>
            </button>
            <a class="navbar-brand" th:href="@{/list}">Ardai</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">搜索问题</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li th:if="${session.user==null}"><a th:href="@{/toLogin}">登陆</a></li>
                <li th:if="${session.user!=null}" class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img th:src="@{${session.user.avatar}}" style="width: 40px;border-radius: 50%" /> <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">消息中心</a></li>
                        <li><a th:href="@{/toAddPost}">发布帖子</a></li>
                        <li><a th:href="@{/userInfo(uid=${session.user.id})}">个人资料</a></li>
                        <li><a th:href="@{/logout}">退出登陆</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container" th:if="${session.user!=null}">
    <h1 th:if="${userInfo.id==session.user.id}">我的个人信息:</h1>
    <h1 th:if="${userInfo.id!=session.user.id}">他的个人信息:</h1>
    <h3 th:if="${param.msg!=null}" th:text="${param.msg}" style="color: greenyellow"></h3>
    <form method="post" th:action="@{/editInfo}">
        <input type="hidden" name="id" th:value="${userInfo.id}">
        <div class="form-group">
            <label >头像:</label>
            <img th:src="@{${userInfo.avatar}}" style="width: 200px;margin-left: 80px">
        </div>
        <div class="form-group">
            <label>用户名</label>
            <input th:if="${userInfo.id==session.user.id}" th:value="${userInfo.username}" type="text" class="form-control" name="username"  placeholder="用户名">
            <input th:if="${userInfo.id!=session.user.id}" th:value="${userInfo.username}" type="text" class="form-control" name="username"  placeholder="用户名" readonly>
        </div>
        <div class="form-group">
            <label >邮箱</label>
            <input th:if="${userInfo.id==session.user.id}"  th:value="${userInfo.email}" type="email" class="form-control" name="email"  placeholder="邮箱">
            <input th:if="${userInfo.id!=session.user.id}" th:value="${userInfo.email}" type="email" class="form-control" name="email"  placeholder="邮箱" readonly>
        </div>
        <div class="form-group">
            <label >github地址</label>
            <input th:if="${userInfo.id==session.user.id}" th:value="${userInfo.gitAddress}" type="text" class="form-control" name="gitAddress"  placeholder="github地址">
            <input th:if="${userInfo.id!=session.user.id}" th:value="${userInfo.gitAddress}" type="text" class="form-control" name="gitAddress"  placeholder="github地址" readonly>
        </div>
        <div class="form-group">
            <label >签名</label>
            <input th:if="${userInfo.id==session.user.id}" th:value="${userInfo.sign}" type="text" class="form-control" name="sign"  placeholder="签名">
            <input th:if="${userInfo.id!=session.user.id}" th:value="${userInfo.sign}" type="text" class="form-control" name="sign"  placeholder="签名" readonly>
        </div>
        <button th:if="${userInfo.id==session.user.id}" type="submit" class="btn btn-success">更新资料</button>&nbsp;&nbsp;&nbsp;
        <a th:href="@{/list}">返回首页</a>
</form>
</div>
<div class="container" th:if="${session.user==null}">
    <h1 >他的个人信息:</h1>
    <form method="post" th:action="@{/editInfo}">
        <input type="hidden" name="id" th:value="${userInfo.id}">
        <div class="form-group">
            <label >头像:</label>
            <img th:src="@{${userInfo.avatar}}" style="width: 200px;margin-left: 80px">
        </div>
        <div class="form-group">
            <label>用户名</label>
            <input  th:value="${userInfo.username}" type="text" class="form-control" name="username"  placeholder="用户名" readonly>
        </div>
        <div class="form-group">
            <label >邮箱</label>
            <input  th:value="${userInfo.email}" type="email" class="form-control" name="email"  placeholder="邮箱" readonly>
        </div>
        <div class="form-group">
            <label >github地址</label>
            <input  th:value="${userInfo.gitAddress}" type="text" class="form-control" name="gitAddress"  placeholder="github地址" readonly>
        </div>
        <div class="form-group">
            <label >签名</label>
            <input  th:value="${userInfo.sign}" type="text" class="form-control" name="sign"  placeholder="签名" readonly>
        </div>
        <a th:href="@{/list}">返回首页</a>
    </form>
</div>
</body>
</html>